Algorithm for dtmf detection

ABSTRACT

The calculation for DFT(Discrete Fourier Transform) is too much in prior art, so the present invention provides a new method DMFT(Discrete Multi-Frequency Transform) for calculation. For example, in prior art, to determine a DTMF signal “3”, the calculation must be performed for k=96˜92 (frequency 1477 Hz with tolerance ±2.5%) and k=45˜43 (frequency 697 Hz with tolerance ±2.5%), total 8 of X[k] value have to be calculated, but the present invention performs a single calculation of X[k] for each frequency. To determine a DTMF signal “3”, only a high frequency of X[k] and a low frequency of X[k] are required to calculate.

FIELD OF THE INVENTION

The present invention relates to a new algorithm for DTMF detection, and more particularly to an algorithm for reducing calculation by utilizing optimal phase or gain.

BACKGROUND OF THE INVENTION

DTMF (Dual-Tone Multi-Frequency) signals are broadly used in PSTN (Public Switched Telecommunication Network) for telephone dialing, data input, voice mail and remote control of consumer products. DTMF signals are used for transmitting numbers. Table 1 shows the combination of DTMF high frequency and low frequency for each telephone key, for example, push the key “1” means two signals of frequency 697 Hz and 1209 Hz are outputted, and so on.

TABLE 1 high freq. low freq. 1209 Hz 1336 Hz 1477 Hz 1633 Hz 697 Hz 1 2 3 A 770 Hz 4 5 6 B 852 Hz 7 8 9 C 941 Hz * 0 # D

In accordance with the ITU (International Telecommunication Union) standard, the acceptable tolerance for DTMF frequency is ±1.5%; if the frequency deviation exceeds ±3.5%, then it is unaccepatable; for frequency deviation between ±1.5%˜±3.5%, the user decides it is acceptable or unaccepatable. The reason that ITU specifies the acceptable tolerance for DTMF frequency is because a signal transmitting or converting between devices may induce frequency shift. A DTMF signal is composed of a high frequency signal and a low frequency signal.

In prior art, DFT (Discrete Fourier Transform) method is used for detecting DTMF signals, the signals in time domain is converted into a spectrum in frequency domain, as shown in FIG. 1. In FIG. 1, the sampling length N is 512, the sampling frequency SR is 8000 Hz, a detection of high frequency 1477 Hz for key “3” is performed, in which k is proportional to frequency (k=1 corresponds to 15.625 Hz), so the k corresponding to 1477 Hz is 940528≈95, while the k corresponding to 697 Hz is 44.608≈44, as shown in FIG. 2. The formula is as below:

$f = {\left. {k*\frac{SR}{N}}\Rightarrow k \right. = {\frac{f*N}{SR} = {\frac{1477*512}{8000} = {94.528.}}}}$

The acceptable tolerance for DTMF frequency is ±2.5% according to the present invention.

As the above setting, 512 samplings are taken each time, and the frequencies contained in the 512 samplings are analyzed, with frequency range 0 Hz˜8000 Hz. The acceptable range of k around 1477 Hz and 697 Hz are calculated as below:

f: 1477 Hz

$k = {\frac{f*N}{SR} = {\frac{1477*512}{8000} = 94.528}}$

upper limit

${k*\left( {1 + {1.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 + {1.5\%}} \right)} = {{\frac{1477*512}{8000}*\left( {1 + {1.5\%}} \right)} = 95.94592}}$

lower limit

${k*\left( {1 - {1.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 - {1.5\%}} \right)} = {{\frac{1477*512}{8000}*\left( {1 - {1.5\%}} \right)} = 93.11008}}$

The upper limit and the lower limit above are the acceptable range specified by ITU.

upper limit

${k*\left( {1 + {2.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 + {2.5\%}} \right)} = {{\frac{1477*512}{8000}*\left( {1 + {2.5\%}} \right)} = 96.8912}}$

lower limit

${k*\left( {1 - {2.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 - {2.5\%}} \right)} = {{\frac{1477*512}{8000}*\left( {1 - {2.5\%}} \right)} = 92.1648}}$

The upper limit and the lower limit above are the acceptable range specified by the present invention.

f: 697 Hz

$k = {\frac{f*N}{SR} = {\frac{697*512}{8000} = 44.608}}$

upper limit

${k*\left( {1 + {1.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 + {1.5\%}} \right)} = {{\frac{697*512}{8000}*\left( {1 + {1.5\%}} \right)} = 45.27712}}$

lower limit

${k*\left( {1 - {1.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 - {1.5\%}} \right)} = {{\frac{697*512}{8000}*\left( {1 - {1.5\%}} \right)} = 43.93888}}$

The upper limit and the lower limit above are the acceptable range specified by ITU.

upper limit

${k*\left( {1 + {2.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 + {2.5\%}} \right)} = {{\frac{697*512}{8000}*\left( {1 + {2.5\%}} \right)} = 45.7232}}$

lower limit

${k*\left( {1 - {2.5\%}} \right)} = {{\frac{f*N}{SR}*\left( {1 - {2.5\%}} \right)} = {{\frac{697*512}{8000}*\left( {1 - {2.5\%}} \right)} = 43.4928}}$

The upper limit and the lower limit above are the acceptable range specified by the present invention.

All of the above k values must be integer, since the index values in memory array of communication hardware device or computer system are integers. In judging if DTMF is “3”, five points of K=96˜92 (frequency tolerance range ±2.5% of 1477 Hz) and three points of K=45˜43 (frequency tolerance range ±2.5% of 697 Hz) have to be checked to see if a minimum value exists for each of the 8 points.

In prior art, the calculation formula of DFT is as below:

$\begin{matrix} {{X\lbrack k\rbrack} = {\sum_{n = 0}^{N - 1}{{x\lbrack n\rbrack}W_{N}^{kn}}}} \\ {= {\sum_{n = 0}^{N - 1}{{x\lbrack n\rbrack}^{j\frac{2\pi}{N}{kn}}}}} \\ {{= {\sum_{n = 0}^{N - 1}{{x\lbrack n\rbrack}\left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; s\; {{in}\left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}},} \end{matrix}$ k = 0, …  , N − 1

in which N is 512, n is 0˜512, k is also 0˜512. X[k] is the height of spectrum for frequency k, x[n] is the height of the n point in time domain. From the above formula, in order to calculate each X[k], 512×2 mutiplications and 512×2-2 additions are needed, the calculation is really too much.

The table below are concluded from the above formula to describe the calculation required for different K range in prior art DFT.

K range calculation required for DFT 1 (2N, 2N − 2) 2 (4N, 4N − 4) 3 (6N, 6N − 6) 4 (8N, 8N − 8) 5 (10N, 10N − 10) 6 (12N, 12N − 12)

As shown in the above table of calculation required for DFT, the more the K range is increased, the calculation will be increased by multiples, the required calculation will grow up dramatically.

SUMMARY OF THE INVENTION

The object of the present invention is to provide an algorithm for DTMF detection. In detecting DTMF signals, the signals x[n] in time domain is converted into a spectrum in frequency domain. Let the sampling length is N, and perform calculation on M points of the spectrum,

$\begin{matrix} {{\overset{\sim}{X}\lbrack k\rbrack} = {\sum\limits_{k = 0}^{M - 1}\; {X\lbrack k\rbrack}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; W_{N}^{kn}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; ^{j\frac{2\pi}{N}{kn}}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{k = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \end{matrix}$

in which x[k] is the signal value at the k point of the spectrum, X[k] is the calculation result on M points of the spectrum,

$m = {\frac{f*N*5\%}{SR} = {\frac{697*512*5\%}{8000} = {2.2304 \cong 3}}}$

In order to avoid trembling wave in pass-band of the frequency domain or to reduce the trembling degree, so as to make it work as a square wave filter like Butterworth or Chebyshev, a θ degree or A gain is added to the above formula to control the wave shape, as shown below:

$\begin{matrix} {{\overset{\Cup}{X}\lbrack k\rbrack} = {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; {\overset{\Cup}{W}}_{N\theta}^{kn}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; ^{{{- j}\frac{2\pi \; {n{({k + m})}}}{N}} + {({m\; \theta})}}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)} - {j\; {\sin \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)}}} \right\}}}}} \end{matrix}$

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows schematically that the signal in time domain is converted into a spectrum in frequency domain.

FIG. 2 shows schematically that k is proportional to frequency.

FIG. 3 shows schematically that a θ degree is added to control the wave shape.

DETAILED DESCRIPTIONS OF THE PREFERRED EMBODIMENTS

Since the calculation for DFT is too much in prior art, the present invention therefore provides a new algorithm DMFT (Discrete Multi-Frequency Transform).

In prior art of DFT, in order to judge a DTMF signal “3”, five points of K=96˜92 (frequency tolerance range ±2.5% of 1477 Hz) and three points of K=45˜43 (frequency tolerance range ±2.5% of 697 Hz) have to be calculated, i.e. the value of X[k] must be calculated 8 times consecutively. But in the present invention the value of X[k] is only calculated once for each frequency. To detect a DTMF signal “3”, a high frequency and a low frequency are required for calculation of X[k], the mathematical formula is as below:

$\begin{matrix} {{\overset{\sim}{X}\lbrack k\rbrack} = {\sum\limits_{k = 0}^{M - 1}\; {X\lbrack k\rbrack}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; W_{N}^{kn}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; ^{j\frac{2\pi}{N}{kn}}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{k = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \end{matrix}$

M is the length of k. If k=96˜92, then M is 5; if k=45˜43, then M=3. The cosine value and the sine value can be added individually, and then multiplied with x[n] so as to save a lot of calculation.

However, when the cosine value and the sine value are added individually, elimination or superposition of the phase will occur to make a smooth wave become a continuous trembling wave. Therefore the present invention adds a θ degree to control the wave shape, so that there is no trembling wave in the Pass-band of the frequency domain, or to reduce the trembling degree thereof, and make it work as a square wave filter like Butterworth or Chebyshev. Renew the formula as below:

$\begin{matrix} {{\overset{\Cup}{X}\lbrack k\rbrack} = {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; {\overset{\Cup}{W}}_{N\theta}^{kn}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; ^{{{- j}\frac{2\pi \; {n{({k + m})}}}{N}} + {({m\; \theta})}}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)} - {j\; {\sin \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)}}} \right\}}}}} \end{matrix}$

FIG. 3 shows schematically that a θ degree is added to control wave shape. Each individual wave is the DFT wave for each X[k]. As shown in the top graph in FIG. 3, even the individual waves are added directly, the correct DTMF signal cannot be judged. The present invention provides the new algorithm, and is shown in the middle graph and the bottom graph in FIG. 3, in which a best θ degree is added to make the individual waves to be added so as to form an optimized square wave filter.

The scope of the present invention depends upon the following claims, and is not limited by the above embodiments. 

What is claimed is:
 1. An algorithm for DTMF (Dual-Tone Multi-Frequency) detection, in detecting DTMF signals, the signals x[n] in time domain is converted into a spectrum in frequency domain, the sampling length is N, and perform calculation on M points of the spectrum within K frequency range, $\begin{matrix} {{\overset{\sim}{X}\lbrack k\rbrack} = {\sum\limits_{k = 0}^{M - 1}\; {X\lbrack k\rbrack}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; W_{N}^{kn}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; ^{j\frac{2\pi \; n}{N}{kn}}}}}} \\ {= {\sum\limits_{k = 0}^{M - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{n = 0}^{N - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{k = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi}{N}{nk}} \right)} - {j\; {\sin \left( {\frac{2\pi}{N}{nk}} \right)}}} \right\}}}}} \end{matrix}$ in which x[k] is the signal value at the k point of the spectrum, X[k] is the calculation result on M points of the spectrum.
 2. The algorithm for DTMF (Dual-Tone Multi-Frequency) detection according to claim 1, $\begin{matrix} {{\overset{\Cup}{X}\lbrack k\rbrack} = {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; {\overset{\Cup}{W}}_{N\theta}^{kn}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; ^{{{- j}\frac{2\pi \; {n{({k + m})}}}{N}} + {({m\; \theta})}}}}}} \\ {= {\sum\limits_{n = 0}^{N - 1}\; {{x\lbrack n\rbrack}{\sum\limits_{m = 0}^{M - 1}\; \left\{ {{\cos \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)} - {j\; {\sin \left( {\frac{2\pi \; {n\left( {k + m} \right)}}{N} + \left( {m\; \theta} \right)} \right)}}} \right\}}}}} \end{matrix}$ wherein the phase θ is a degree added to control the wave shape, so that there is no trembling wave, and make it work as a square wave filter to filter out quickly the required frequency and signal. 